package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Rygl;
import com.ruoyi.system.service.IRyglService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * ryglController
 * 
 * @author ruoyi
 * @date 2024-03-27
 */
@RestController
@RequestMapping("/system/rygl")
public class RyglController extends BaseController
{
    @Autowired
    private IRyglService ryglService;

    /**
     * 查询rygl列表
     */
    @PreAuthorize("@ss.hasPermi('system:rygl:list')")
    @GetMapping("/list")
    public TableDataInfo list(Rygl rygl)
    {
        startPage();
        List<Rygl> list = ryglService.selectRyglList(rygl);
        return getDataTable(list);
    }

    /**
     * 导出rygl列表
     */
    @PreAuthorize("@ss.hasPermi('system:rygl:export')")
    @Log(title = "rygl", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Rygl rygl)
    {
        List<Rygl> list = ryglService.selectRyglList(rygl);
        ExcelUtil<Rygl> util = new ExcelUtil<Rygl>(Rygl.class);
        util.exportExcel(response, list, "rygl数据");
    }

    /**
     * 获取rygl详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:rygl:query')")
    @GetMapping(value = "/{bmname}")
    public AjaxResult getInfo(@PathVariable("bmname") String bmname)
    {
        return success(ryglService.selectRyglByBmname(bmname));
    }

    /**
     * 新增rygl
     */
    @PreAuthorize("@ss.hasPermi('system:rygl:add')")
    @Log(title = "rygl", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Rygl rygl)
    {
        return toAjax(ryglService.insertRygl(rygl));
    }

    /**
     * 修改rygl
     */
    @PreAuthorize("@ss.hasPermi('system:rygl:edit')")
    @Log(title = "rygl", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Rygl rygl)
    {
        return toAjax(ryglService.updateRygl(rygl));
    }

    /**
     * 删除rygl
     */
    @PreAuthorize("@ss.hasPermi('system:rygl:remove')")
    @Log(title = "rygl", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bmnames}")
    public AjaxResult remove(@PathVariable String[] bmnames)
    {
        return toAjax(ryglService.deleteRyglByBmnames(bmnames));
    }
}
